package com.lg.util;

import java.util.List;

/**
 *@Author liujun
 *@2009-11-23上午10:29:48
 *@public class PageUtilBean{ }
 */
public class PageUtilBean {

	private int onePageCount = 5; // 每页显示的记录数

	private int resultCount; //  总共有的记录数

	private int currentPage; //  当前页

	private int pageCount; //总共有多少页数
	
	private int start;//数据库开始位置
	
	private List modelList;
	
	
	public int getStart() {
		return (this.currentPage-1)*this.onePageCount;
	}


	public int getResultCount(){
		return this.resultCount;
	}
	
	public int getOnePageCount(){
		return this.onePageCount;
	}
	
	public int getCurrentPage(){
		return this.currentPage;
	}
	
	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public void setCurrentPage(String currentPage) {
		if (currentPage == null || "".equals(currentPage)|| "null".equals(currentPage) ) {
			currentPage = "1";
		}else if(Integer.valueOf(currentPage)<=0){
			currentPage = "1";
		}
		
		this.currentPage = Integer.parseInt(currentPage);
		
		if(this.currentPage>this.pageCount){
			this.currentPage = this.pageCount;
		}

	}

	
	public void setOnePageCount(String onePageCount) {
		if(onePageCount!=null)
		this.onePageCount = Integer.parseInt(onePageCount);
	}

	public void setResultCount(int resultCount) {
		
		this.resultCount = resultCount;

		this.pageCount = 0;
		if (this.resultCount % onePageCount == 0) {
			pageCount = this.resultCount / onePageCount;
		} else {
			pageCount = this.resultCount / onePageCount + 1;
		}
	}
	
	public  void setModelList(List modelList){
		this.modelList=modelList;
	}
	public List getModelList(){
		return modelList;
	}
}
